<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * \brief For results to send back to app.
 */
class JsonResult
{
	// Properties
	var $Success;
	var $Error;
	var $Msg;
	var $Data;
}

class Json {

	public function Success($_id, $_text)
	{
		$array = array();
		$array["Success"] = $_id;
		$array["Error"] = 0;
		$array["Msg"] = $_text;
		echo json_encode($array);
	}

	public function Error($_id, $_text)
	{
		$array = array();
		$array["Success"] = 0;
		$array["Error"] = $_id;
		$array["Msg"] = $_text;
		echo json_encode($array);
	}

	public function Encode($items)
	{
		json_encode($items);
	}
	
	/**
	 * \brief Takes the arguments and put it into a json encoded JsonResult.
	 */
	public function GetJsonResult($successStatus, $errorStatus, $msg, $data)
	{
		$jsonContent = new JsonResult();
		$jsonContent->Success = $successStatus;
		$jsonContent->Error = $errorStatus;
		$jsonContent->Msg = $msg;
		$jsonContent->Data = $data;
		
		return(json_encode($jsonContent));
	}
}

?>